/**
 * 
 */
package photoPrint;

import java.util.HashMap;
import java.util.Map;

/**
 * @author filiperosa
 *
 */
public class PhotoCollection implements TADPhotoCollection {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1920572775190191916L;
	private Map<String,TADPhoto> photos;
	
	public PhotoCollection(){
		photos = new HashMap<String, TADPhoto>();
	}

	/* (non-Javadoc)
	 * @see photoPrint.TADPhotoCollection#addPhoto(photoPrint.TADPhoto)
	 */
	public boolean addPhoto(TADPhoto photo) {
		if (photos.isEmpty()||!photos.containsKey(photo.getCode())){
			photos.put(photo.getCode(), photo);
			return true;
		}
		return false;
	}

	/* (non-Javadoc)
	 * @see photoPrint.TADPhotoCollection#removePhoto(java.lang.String)
	 */
	public boolean removePhoto(String id) {
		if (!photos.isEmpty()&&photos.containsKey(id)){
			photos.remove(id);
			return true;
		}
		return false;
	}

	/* (non-Javadoc)
	 * @see photoPrint.TADPhotoCollection#getPhoto(java.lang.String)
	 */
	public TADPhoto getPhoto(String id) {
		if (!photos.isEmpty()&&photos.containsKey(id)){
			return photos.get(id);
		}
		return null;
	}

	public boolean contains(String id) {
		if (!photos.isEmpty()&&photos.containsKey(id)){
			return true;
		}
		return false;
	}

}
